[NET] back: Add GSO features field and check gso_size
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 3 Jul 2006 08:05:18 +0000 (09:05 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 3 Jul 2006 08:05:18 +0000 (09:05 +0100)
This patch adds the as-yet unused GSO features which will contain
protocol-independent bits such as the ECN marker.

It also makes the backend check gso_size to ensure that it is non-zero.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
xen/include/public/io/netif.h

index 5171d0ab02c7e9a8e4c28e7e64b89d9a343836f3..52cb7e7382fdd7487b25fc51ab10c3c51d3bb8df 100644 (file)
@@ -691,6 +691,29 @@ int netbk_get_extras(netif_t *netif, struct netif_extra_info *extras,
        return work_to_do;
 }
 
+static int netbk_set_skb_gso(struct sk_buff *skb, struct netif_extra_info *gso)
+{
+       if (!gso->u.gso.size) {
+               DPRINTK("GSO size must not be zero.\n");
+               return -EINVAL;
+       }
+
+       /* Currently only TCPv4 S.O. is supported. */
+       if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) {
+               DPRINTK("Bad GSO type %d.\n", gso->u.gso.type);
+               return -EINVAL;
+       }
+
+       skb_shinfo(skb)->gso_size = gso->u.gso.size;
+       skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
+
+       /* Header must be checked, and gso_segs computed. */
+       skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
+       skb_shinfo(skb)->gso_segs = 0;
+
+       return 0;
+}
+
 /* Called after netfront has transmitted */
 static void net_tx_action(unsigned long unused)
 {
@@ -819,20 +842,11 @@ static void net_tx_action(unsigned long unused)
                        struct netif_extra_info *gso;
                        gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1];
 
-                       /* Currently on TCPv4 S.O. is supported. */
-                       if (gso->u.gso.type != XEN_NETIF_GSO_TCPV4) {
-                               DPRINTK("Bad GSO type %d.\n", gso->u.gso.type);
+                       if (netbk_set_skb_gso(skb, gso)) {
                                kfree_skb(skb);
                                netbk_tx_err(netif, &txreq, i);
-                               break;
+                               continue;
                        }
-
-                       skb_shinfo(skb)->gso_size = gso->u.gso.size;
-                       skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
-
-                       /* Header must be checked, and gso_segs computed. */
-                       skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
-                       skb_shinfo(skb)->gso_segs = 0;
                }
 
                gnttab_set_map_op(mop, MMAP_VADDR(pending_idx),
index 1c34a906147270a27ebc41ab9b234cfa79915692..36c0ef266c40792162e0721b264a06daf8fb9a25 100644 (file)
@@ -787,7 +787,7 @@ static int network_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        tx->flags |= NETTXF_extra_info;
 
                gso->u.gso.size = skb_shinfo(skb)->gso_size;
-               gso->u.gso.type = XEN_NETIF_GSO_TCPV4;
+               gso->u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
 
                gso->type = XEN_NETIF_EXTRA_TYPE_GSO;
                gso->flags = 0;
index dfd9627fd90017e4f78ac9a267d159292b5f765c..7b219b00a22bfd85f1b3a24606e65bea783b9f67 100644 (file)
@@ -65,7 +65,7 @@ typedef struct netif_tx_request netif_tx_request_t;
 #define XEN_NETIF_EXTRA_FLAG_MORE  (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
 
 /* GSO types - only TCPv4 currently supported. */
-#define XEN_NETIF_GSO_TCPV4        (1)
+#define XEN_NETIF_GSO_TYPE_TCPV4        (1)
 
 /*
  * This structure needs to fit within both netif_tx_request and
@@ -87,7 +87,16 @@ struct netif_extra_info {
              * GSO type. This determines the protocol of the packet and any
              * extra features required to segment the packet properly.
              */
-            uint16_t type; /* XEN_NETIF_GSO_* */
+            uint8_t type; /* XEN_NETIF_GSO_TYPE_* */
+
+            /* Future expansion. */
+            uint8_t pad;
+
+            /*
+             * GSO features. This specifies any extra GSO features required
+             * to process this packet, such as ECN support for TCPv4.
+             */
+            uint16_t features; /* XEN_NETIF_GSO_FEAT_* */
         } gso;
 
         uint16_t pad[3];